/*
 * OptionsController.java
 *
 * @author Michael Hansen
 * @author Lukas Thuernagel
 * @author Soeren Warszus
 */

package risk.options;

import java.awt.event.*;
import javax.swing.*;


public class OptionsController implements ActionListener {
    /**
     * Das zugehoerige OptionsModel
     */
    private OptionsModel model;
    
    /**
     * Das zugehoerige OptionsView
     */
    private OptionsView view;
    
    /**
     * Erzeugt einen neuen OptionsController
     */
    public OptionsController(OptionsModel om, OptionsView ov) {
        this.model = om;
        this.view  = ov;
    }

    /**
     * Lauscht am OptionsView
     * 
     * @param e  ActionEvent
     */
    public void actionPerformed(ActionEvent e) {
        if ("startGame".equals(e.getActionCommand())){
            this.model.validate();
        } else if ("selectedMap".equals(e.getActionCommand())){
            JComboBox cb = (JComboBox)e.getSource();         
            model.setSelectedMap((String)cb.getSelectedItem());
        } else if ("player1".equals(e.getActionCommand())) {
            this.view.enablePlayer(1);
        } else if ("player2".equals(e.getActionCommand())) {
            this.view.enablePlayer(2);
        } else if ("player3".equals(e.getActionCommand())) {
            this.view.enablePlayer(3);
        } else if ("player4".equals(e.getActionCommand())) {
            this.view.enablePlayer(4);
        } else if ("player5".equals(e.getActionCommand())) {
            this.view.enablePlayer(5);
        } else if ("player6".equals(e.getActionCommand())) {
            this.view.enablePlayer(6);
        }
    }
}
